#include "tcar.h"
#include "game.h"

void TCar::move(){
    switch(this->getState()){
    case UP:
        _velocity.x(0);
        _velocity.y(-10);
        break;
    case DOWN:
        _velocity.x(0);
        _velocity.y(10);
        break;
    case RIGHT:
        _velocity.x(10);
        _velocity.y(0);
        break;
    case LEFT:
        _velocity.x(-10);
        _velocity.y(0);
        break;
    case SHOOT:
        TObject* bullet = Game::Instance()->createObject('b');
        bullet -> setPosition(_position);
        bullet -> setVelocity(_velocity*2);
    }

    _state     = 0;
    _position += _velocity;

}

TCar::TCar(TGraphic* graphic)
    : TObject(graphic)
{
    _type  = 'c';
    _state = 0;
    _size.x(20);
    _size.y(20);
}
